//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for DevOpsGuru
public struct DevOpsGuruErrorType: AWSErrorType {
    enum Code: String {
        case accessDeniedException = "AccessDeniedException"
        case conflictException = "ConflictException"
        case internalServerException = "InternalServerException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case serviceQuotaExceededException = "ServiceQuotaExceededException"
        case throttlingException = "ThrottlingException"
        case validationException = "ValidationException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize DevOpsGuru
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    ///  You don't have permissions to perform the requested operation. The user or role that is making the request must have at least one IAM permissions policy attached that grants the required permissions. For more information, see Access Management in the IAM User Guide.
    public static var accessDeniedException: Self { .init(.accessDeniedException) }
    ///  An exception that is thrown when a conflict occurs.
    public static var conflictException: Self { .init(.conflictException) }
    /// An internal failure in an Amazon service occurred.
    public static var internalServerException: Self { .init(.internalServerException) }
    /// A requested resource could not be found
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// The request contains a value that exceeds a maximum quota.
    public static var serviceQuotaExceededException: Self { .init(.serviceQuotaExceededException) }
    /// The request was denied due to a request throttling.
    public static var throttlingException: Self { .init(.throttlingException) }
    ///  Contains information about data passed in to a field during a request that is not valid.
    public static var validationException: Self { .init(.validationException) }
}

extension DevOpsGuruErrorType: Equatable {
    public static func == (lhs: DevOpsGuruErrorType, rhs: DevOpsGuruErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension DevOpsGuruErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
